<?php
namespace App\Library\System\Model;

use App\Library\System\Model;

/**
 * Skill Model
 *
 * @category   Model
 * @package    App\Library\System\Model
 * @author     Tin Nguyen <tinntt@peslook.com>
 * @copyright  Peslook
 * @version    1.0
 * @since      Class available since Release 1.0
 */
class SkillModel extends Model
{
    /**
     * Constructor
     *
     * @param int|string $id , int $type
     */
    public function __construct($id)
    {
        parent::__construct();

        if (is_numeric($id)) {
            $skill = $this->one($this->select()
                    ->from('skill')
                    ->where(array(
                        'id' => $id
                    ))
            );
        } else {
            $skill = $this->one($this->select()
                    ->from('skill')
                    ->where(array(
                        'alias' => $id
                    ))
            );

        }

        // Integrate user's information into this object as properties
        if ($skill) {
            $this->add($skill);
        }

    }

    /**
     * Get relative skills
     *
     * @return array|\ArrayObject|null|\Zend\Db\ResultSet\ResultSet
     */
    public function getFriend()
    {
        return $this->more($this->select()
                ->columns(
                    array(
                        'alias'
                    )
                )
                ->from('skill')
                ->where(array(
                    'category' => $this->category
                ))
        );

    }

    /**
     * is Valid ?
     * Check the skill if it's valid
     *
     * @return bool
     */
    public function isValid()
    {
        return isset($this->id) ? true : false;
    }

    /**
     * Get skill's name
     *
     * @return string
     */
    public function getSkillName()
    {
        return $this->skillname;
    }

    public function getAlias()
    {
        return $this->alias;
    }

    public function getDescription()
    {
        return $this->description;
    }

    public function getImage()
    {
        return $this->image;
    }

    public function getType()
    {
        return $this->type;
    }

    public function getLink()
    {
        return $this->link;
    }

    public function getLinkEdit()
    {
        return $this->linkedit;
    }

    public function getPeople()
    {
        return $this->people;
    }

    public function getJobs()
    {
        return $this->jobs;
    }
} 